package io.renren.modules.cs.controller;

import java.util.Arrays;
import java.util.Map;

import io.renren.common.annotation.SysLog;
import io.renren.common.validator.ValidatorUtils;
import io.renren.common.validator.group.AddGroup;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.cs.entity.ZrzyhghjEntity;
import io.renren.modules.cs.service.ZrzyhghjService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 自然资源和规划局测试表
 *
 * @author zj
 * @email 465189260@qq.com
 * @date 2020-08-12 14:20:01
 */
@RestController
@RequestMapping("cs/zrzyhghj")
public class ZrzyhghjController {
    @Autowired
    private ZrzyhghjService zrzyhghjService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("cs:zrzyhghj:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = zrzyhghjService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{zbsjId}")
    @RequiresPermissions("cs:zrzyhghj:info")
    public R info(@PathVariable("zbsjId") Long zbsjId){
        ZrzyhghjEntity zrzyhghj = zrzyhghjService.getById(zbsjId);

        return R.ok().put("zrzyhghj", zrzyhghj);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("cs:zrzyhghj:save")
    public R save(@RequestBody ZrzyhghjEntity zrzyhghj){

        ValidatorUtils.validateEntity(zrzyhghj, AddGroup.class);
        zrzyhghjService.save(zrzyhghj);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("cs:zrzyhghj:update")
    public R update(@RequestBody ZrzyhghjEntity zrzyhghj){

        ValidatorUtils.validateEntity(zrzyhghj);

        zrzyhghjService.updateById(zrzyhghj);
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("cs:zrzyhghj:delete")
    public R delete(@RequestBody Long[] zbsjIds){
        zrzyhghjService.removeByIds(Arrays.asList(zbsjIds));

        return R.ok();
    }

}
